package errors

import (
	"errors"
	"fmt"
)

var (
	ErrTaskRunningPanic = errors.New("taskPool: Task运行时异常")
	ErrTask             = errors.New("taskPool: 不允许提交nil任务")
	ErrQueueFull        = errors.New("任务池未启动，缓冲任务已满，无法添加新任务")
)

func ErrNumGRelated(initGNum int32, coreGNum int32, maxGNum int32) error {
	return fmt.Errorf("taskPool: goroutine设置数量间关系不满足：0 < initGNum <= coreGNum <= maxGNum; initGNum: %d, coreGNum: %d, maxGNum: %d", initGNum, coreGNum, maxGNum)
}

func ErrQueueBacklogRate(queueBacklogRate float64) error {
	return fmt.Errorf("taskPool: queueBacklogRate err; current rate: %f", queueBacklogRate)
}

func ErrSubmitState(currentState string) error {
	return fmt.Errorf("taskPool: currentState can not submit; current state: %s", currentState)
}

func ErrStartState(currentState string) error {
	return fmt.Errorf("taskPool: currentState can not start; current state: %s", currentState)
}

func ErrStopState(currentState string) error {
	return fmt.Errorf("taskPool: currentState can not stop; current state: %s", currentState)
}

func ErrUnknownState(state int32) error {
	return fmt.Errorf("taskPool: unknown state %d", state)
}
